/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-04 16:21:36
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-04 16:30:55
 * @Description: file content
 */

#include "apue.h"
#include <sys/sysmacros.h>

int main(int argc, char *argv[])
{
    struct  stat buf;

    for (int i = 1; i < argc; i++)
    {
        printf("%s: ", argv[i]);
        if (stat(argv[i], &buf) < 0)
        {
            err_ret("stat error");
            continue;
        }

        printf("dev = %d/%d", major(buf.st_dev), minor(buf.st_dev));
        if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode))
        {
            printf(" (%s) rdev = %d/%d",
                    (S_ISCHR(buf.st_mode))?"character":"block",
                    major(buf.st_rdev), minor(buf.st_dev));
        }
        printf("\n");
    }

    exit(0);
}
